//
//  DArenVC.m
//  Hand-held_kitchen
//
//  Created by 张张烨 on 16/1/20.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "DArenVC.h"
#import "ZongTouwenjian.pch"
#import "DaRencell.h"
#import "DaRenMoel.h"
@interface DArenVC ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,retain)UITableView *tableView;
@property(nonatomic,retain)NSMutableArray *dataArr;/**<  table 数组 */
@property(nonatomic,retain)NSMutableArray *idArr;/**<  id数组 */
@end

@implementation DArenVC
-(void)dealloc
{
    [_tableView  release];
    [_dataArr release];
    [_idArr release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self data];
    [self table];
     self.idArr  = [NSMutableArray array];
}

-(void)data
{
        NSString *str = @"http://api.izhangchu.com/?size=20&page=1&methodName=TalentRecommend&version=4.3&";
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    //    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    [manager POST:str parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSArray *arr = responseObject[@"data"][@"data"];
        self.dataArr = [DaRenMoel modelHanderWithArray:arr];
        
       
//        NSMutableArray *arr1 = [NSMutableArray array];
//        for (NSDictionary *dic in arr) {
//            arr1 =dic[@"post"];
//            for (DaRenMoel *m in arr1[0]) {
//                [self.idArr setValue:m forKey:@"id"];
//                NSLog(@"%@",_idArr);
//            }
//        }
        
        [_tableView reloadData];
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
}

-(void)table
{
    self.tableView = [[UITableView alloc]initWithFrame:self.view.frame style:(UITableViewStylePlain)];
    _tableView.dataSource =self;
    _tableView.delegate = self;
    [self.view addSubview:_tableView];
    
    [_tableView registerClass:[DaRencell class] forCellReuseIdentifier:@"cell"];
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    DaRencell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    DaRenMoel *m = _dataArr[indexPath.row];
    [cell.touxiang sd_setImageWithURL:[NSURL URLWithString:m.head_img]];
    cell.nicheng.text = m.nick;
    cell.neirong.text = [NSString stringWithFormat:@"      %@",m.declaration];
    
    
    return cell;
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100 * GAO;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
